--
-- Author:      name
-- DateTime:    2018-05-05 15:46:35
-- Description: 炸金花服务
local skynet = require "skynet"
local queue = require "skynet.queue"

local Objects = require "Objects"
local Message = require "pinshi.Message"
local Command = require "pinshi.Command"
local Machine = require("pinshi.Machine")
local Rule = require("pinshi.Rule")

local myqueue = queue()
local param = {...}

local gameName = 'pinshi'
local tableid = tonumber(param[1])
local room_type = tonumber(param[2])
g_objects = Objects.new()


local function init()

	local message = Message.new(gameName)
	g_objects:add(message)
	local rule = Rule.new()
	g_objects:add(rule)
	local machine = Machine.new(tableid, rule)
	g_objects:add(machine)
	machine:start()
	local command = Command.new(message, machine)
	g_objects:add(command)
	g_objects:hotfix(gameName)
	
	
	local f = message:dispatch()
	function _queue( session, source, cmd, ...)		
		local resut = myqueue(f, session, source, cmd, ...)
		return result
	end	
	skynet.dispatch("lua",_queue)

end

---------------------------------------------------------
-- skynet
---------------------------------------------------------
skynet.start(function()
	init()
end)